/**
 * Created by Administrator on 2016/9/24.
 */
var $num = $('#num');
var $numAdd = $('.numAdd');
var $numReduce = $('.numReduce');

$numAdd.click(function () {
    $num.val(parseInt($num.val())+1);
});
$numReduce.click(function () {
    if(parseInt($num.val())>1){
        $num.val(parseInt($num.val())-1);
    }
});

//=============================提交
(function () {
    $('input[type="submit"]').click(function (e) {
        e.preventDefault();
        var $tel = $('#tel').val();
        var $typq = $('input[name="1"]');
        for(var i=0;i<$typq.length;i++){
            if($($typq[i]).is(':checked')) {
                var typqNum = i;
            }
        }
        // console.log()
        var data ={
            id:'xxxx',
            fee:'30',
            number:$('#num').val(),
            serve_type:'1',
            phone:$tel,
            pay_type:'1',
            typq:typqNum
        }
        $.post('/order/submit',data,function (res) {
            if(res.code == 0){
                alert('成功购买'+res.num+'件此商品！');
            }else {
                alert('购买失败！');
            }
        })
    })
})();